furny.util
Class IOUtils

java.lang.Object
  extended by furny.util.IOUtils

public final class IOUtils
extends java.lang.Object

Utility class for handling object<->byte[] conversion.

Since:
11.08.2012
Author:
Stephan Dreyer

Field Summary
private static java.util.logging.Logger LOGGER
           
 
Constructor Summary
private IOUtils()
          Instantiation is not allowed.
 
Method Summary
static java.awt.image.BufferedImage createImage(byte[] bytes)
          Converts a byte array of image data to an image.
static com.jme3.scene.Node createNode(byte[] bytes)
          Converts a byte array to a JME node.
static byte[] getBytes(java.io.File f)
          Reads a file into a byte array.
static byte[] getBytes(java.awt.Image image)
          Converts an Image to a byte array.
static byte[] getBytes(com.jme3.scene.Node node)
          Converts a JME node to a byte array.
private static java.util.List<com.jme3.material.Material> getMaterials(java.util.List<com.jme3.material.Material> list, com.jme3.scene.Spatial node)
          Gets recursively all materials from a spatial.
static java.util.List<com.jme3.material.Material> getMaterials(com.jme3.scene.Node node)
          Gets all materials from a node.
static java.util.Map<com.jme3.texture.Texture,TextureData> getTextureData(com.jme3.material.Material mat)
          Get a map of textures and texture data from a material.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

private static final java.util.logging.Logger LOGGER
Constructor Detail

IOUtils

private IOUtils()
Instantiation is not allowed.

Since:
11.08.2012
Method Detail

getBytes

public static byte[] getBytes(java.awt.Image image)
                       throws java.io.IOException
Converts an Image to a byte array. The data will be in PNG format.

Parameters:
image - Image to convert.
Returns:
A byte array of PNG data.
Throws:
java.io.IOException - if writing the PNG data fails.
Since:
11.08.2012

createImage

public static java.awt.image.BufferedImage createImage(byte[] bytes)
                                                throws java.io.IOException
Converts a byte array of image data to an image.

Parameters:
bytes - The byte array, e.g. in JPG or PNG format.
Returns:
The image.
Throws:
java.io.IOException - if reading the image data fails.
Since:
11.08.2012

getBytes

public static byte[] getBytes(com.jme3.scene.Node node)
                       throws java.io.IOException
Converts a JME node to a byte array.

Parameters:
node - The node to convert.
Returns:
The byte array.
Throws:
java.io.IOException - if writing the byte array fails.
Since:
11.08.2012

getTextureData

public static java.util.Map<com.jme3.texture.Texture,TextureData> getTextureData(com.jme3.material.Material mat)
                                                                          throws java.io.IOException
Get a map of textures and texture data from a material.

Parameters:
mat - The material.
Returns:
A map of textures associated with texture data.
Throws:
java.io.IOException - if writing the byte array fails.
Since:
11.08.2012

getBytes

public static byte[] getBytes(java.io.File f)
                       throws java.io.IOException
Reads a file into a byte array.

Parameters:
f - The file to read.
Returns:
The byte array with the files content.
Throws:
java.io.IOException - if reading the file fails.
Since:
11.08.2012

getMaterials

public static java.util.List<com.jme3.material.Material> getMaterials(com.jme3.scene.Node node)
Gets all materials from a node.

Parameters:
node - The node to get materials from.
Returns:
The list of materials.
Since:
11.08.2012

getMaterials

private static java.util.List<com.jme3.material.Material> getMaterials(java.util.List<com.jme3.material.Material> list,
                                                                       com.jme3.scene.Spatial node)
Gets recursively all materials from a spatial.

Parameters:
list - Target list for the materials.
node - The spatial (e.g. node).
Returns:
The target list.
Since:
11.08.2012

createNode

public static com.jme3.scene.Node createNode(byte[] bytes)
                                      throws java.io.IOException
Converts a byte array to a JME node.

Parameters:
bytes - The data of the node.
Returns:
The node.
Throws:
java.io.IOException - if reading the byte array fails or the data is no node data.
Since:
11.08.2012